package dao

import (
	"zy7/global"
	"zy7/internal/model"
)

func CreateUser(user *model.Users) bool {
	if err := global.DB.Create(&user).Error; err != nil {
		return false
	}
	return true
}
func GetUserMobile(mobile string) model.Users {
	var result model.Users
	err := global.DB.Where("mobile = ?", mobile).Find(&result).Error
	if err != nil {
		return model.Users{}
	}
	return result
}

func GetUserMobileAndPassword(mobile string, password string) model.Users {
	var result model.Users
	err := global.DB.Where("mobile = ?", mobile).Where("password = ?", password).Find(&result).Error
	if err != nil {
		return model.Users{}
	}
	return result
}
func GetUser(tel string) model.Users {
	var result model.Users
	if err := global.DB.Where("tel=?", tel).Find(&result).Error; err != nil {
		return model.Users{}
	}
	return result
}
func ListUser() []model.Users {
	var result []model.Users
	if err := global.DB.Find(&result).Error; err != nil {
		return []model.Users{}
	}
	return result
}
